#include <16F877.h> 
#use delay(clock=8000000) 
#fuses HS,NOWDT 
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,stream=RS232,bits=8) 
#include <stdio.h> 

//pinnen van de network cable uitleescomponent definieren
#define pin_Reset          PIN_B6      // bruin-wit
#define pin_Load           PIN_B5      // Groen
#define pin_Ground2        PIN_B4      // Groen-wit
#define pin_Clock          PIN_B3      // Blauw
#define pin_Ground1        PIN_B2      // Blauw-wit
#define pin_Data           PIN_B1      // Oranje   
#define pin_Power          PIN_B0      // Orjanje-wit

//variabelen definieren 
const int NumberOfBoards = 27;   //27borden totaal
const long NumberOfSensors =  NumberOfBoards * 16;
  
void clock(VOID) 
{
   output_bit (pin_Clock, 1);
   output_bit (pin_Clock, 0);
   Delay_us (100);
   //Delay_ms (1);
}
  
void reset(VOID) 
{
   output_bit (pin_Reset, 1);
   output_bit (pin_Reset, 0);
}
  
void main(VOID) 
{
   set_tris_b (0x02); 
   output_bit(pin_Ground1, 0); 
   output_bit(pin_Ground2, 0);
   output_bit(pin_Power, 1);
   
   WHILE (1)
   {
      long i;
      int k;
      //set de bitvalues van de network cable uitleescomponent
      output_bit (pin_Load, 1);
      clock ();
      reset ();
      output_bit (pin_Load, 0);  
      Delay_ms (333);
      i = 0;
      WHILE (i < NumberOfSensors) //Alle sensoren uitlezen
      {  
         //Lees pin_Data en filter sensoren die 1 geven(stuk zijn)
         if ((input(pin_Data) != 0) && (i != 25)&& (i != 271)&& (i != 122)&& (i != 125)&& (i != 268) && (i != 83)&& (i != 113)&& (i != 116)&& (i != 118)&& (i != 128)&& (i != 153)&& (i != 154)&& (i != 201)&&  (i != 256)&& (i != 259)&& (i != 260)&& (i != 266)&& (i != 327)&&(i != 335)&& (i != 370)&& (i != 395)&& (i != 408)&& (i != 409)&& (i != 413)&&(i != 418)&& (i != 424)) 
         { 
            printf("%ld;", i);
         }
         i++;
         clock ();
      }   
   }       
 }
